<?php 
$emailAddress = get_post_meta($post->ID, "emailAddress", true);

$send_email = dirname(__FILE__).'/sendemail.php';
include($send_email)
?>

<div class="archive">
<?php 
if ( have_posts() ) : ?>
<?php  while ( have_posts() ) : the_post();?>

<div class="hentry-meta"><h1> 
<?php if ( has_post_thumbnail() ) the_post_thumbnail('company-logo'); ?> <?php the_title(); ?></h1></div>
<section class="general-wrapper product">

<?php
	$emailAddress=get_post_meta($post->ID, "emailAddress", true);
	$phoneNumber=get_post_meta($post->ID, "phoneNumber", true);
	$contactPerson=get_post_meta($post->ID, "contactPerson", true);
	$siteURL=get_post_meta($post->ID, "siteURL", true);
	$youTubeVideo=get_post_meta($post->ID, "youTubeVideo", true);
	$address=get_post_meta($post->ID, "address", true);
	$product_line = get_post_meta($post->ID, "company_product_line", true);
	
	$url_approve = "javascript:alert('Soon')";
	
	if($siteURL == "")
	{
		$siteURL = 'N/A';
	}elseif(!isValidURL($siteURL))
	{
		$siteURL = '<a style="text-decoration:underline" target="_new" href="http://'.$siteURL.'">'.$siteURL.'</a>';
	}
	else
	{
		$siteURL = '<a style="text-decoration:underline" target="_new" href="'.$siteURL.'">'.$siteURL.'</a>';
	}
?>
<?php if(isset($cmd)): ?>
<div><strong><?php echo $cmd ?></strong></div>
<?php endif; ?>
<h3>Description</h3>
	<p>
    <?php the_content()?>
    </p>
    <br />
<br />

    
        <p><strong style="font-size:16px;">Address</strong>: <?php echo ($address!=""?$address:"N/A"); ?></p>
		<p><strong style="font-size:16px">Tel</strong>: <?php echo ($phoneNumber!=""?$phoneNumber:"N/A"); ?></p>
		<p><strong style="font-size:16px">Email</strong>: <?php echo ($emailAddress!=""?$emailAddress:"N/A"); ?></p>
		<p><strong style="font-size:16px">Website</strong>: <?php echo $siteURL?></p>
        <p><strong style="font-size:16px">Products line</strong>: <?php echo $product_line?></p>
        
        <p><strong style="font-size:16px"><a href="<?php echo $url_approve?>">Approve it</a></strong></p>
<?php 
endwhile;
endif;


function isValidURL($url)
{
	return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
?>

</div>
